<?php
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
ini_set('display_errors', '1');
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class main extends CI_Controller {

    function __construct() {
        parent::__construct();
    }

    public function index() {
        $this->load->library('a_class');
        $class_obj = new a_class();
        $data['class_list'] = $class_obj->get_class_info(CONFIG_ID);

        $this->load->library('a_ad');
        $ad_obj = new a_ad();
        $data['ad_list'] = $ad_obj->get_ad_list_page(2);

        $this->load->library('a_article');
        $article_obj = new a_article();
        $data['article_list'] = $article_obj->get_article_list(CONFIG_ID,2);

        $this->load->library('a_product');
        $product_obj = new a_product();
        $data['product_list'] = $product_obj->get_product_list_page(CONFIG_ID,3);

        $data['block_list'] = $article_obj->get_block_list_page();

        /*新闻动态*/
        $data['news'] = $this->m_public->getRowInfo('ad',array('adname'=>'news'));
        $child_class1 = $this->m_public->getAllInfo('class',array('parentid'=>2,'configid'=>CONFIG_ID));
        $class_arr1 = array();
        foreach($child_class1 as $val){
            $class_arr1[] = $val['classid'];
        }
        $class_str1 = implode(',',$class_arr1);
//        $data['news']['infos'] = $this->m_public->getAllInfo('article','classid in ('.$class_str1.')');
        $news_condition = array(
            'from' => 'article',
            'where' => 'classid in ('.$class_str1.')',
            'order' => 'addtime desc'
        );
        if($class_str1 != '')
            $data['news']['infos'] = $this->m_public->get_list($news_condition);

        /*技术支持*/
        $data['jishuzhichi'] = $this->m_public->getRowInfo('ad',array('adname'=>'technology'));
        $child_class2 = $this->m_public->getAllInfo('class',array('parentid'=>18,'configid'=>CONFIG_ID));
        $class_arr2 = array();
        foreach($child_class2 as $val){
            $class_arr2[] = $val['classid'];
        }
        $class_str2 = implode(',',$class_arr2);
//        $data['jishuzhichi']['infos'] = $this->m_public->getAllInfo('article','classid in ('.$class_str2.')');
        $jishuzhichi_condition = array(
            'from' => 'article',
            'where' => 'classid in ('.$class_str2.')',
            'order' => 'addtime desc'
        );
        if($class_str2 != '')
            $data['jishuzhichi']['infos'] = $this->m_public->get_list($jishuzhichi_condition);

        /*头部,底部数据*/
        $config = $this->m_public->getRowInfo('config',array('configid'=>CONFIG_ID),'copyright,banquan,contact_config,footerinfo');
        $config['contact_config'] = json_decode($config['contact_config'],true);
        $data['config'] = $config;
        $footer_condition = array(
            'from' => 'link',
            'where' => array('isclose'=>0,'typeid'=>1,'configid'=>CONFIG_ID),
            'order' => 'listid'
        );
        $data['footer_info'] = $this->m_public->get_list($footer_condition);

        //print_r($data['ad_list']);
        $this->load->view('../en/index',$data);
    }

    public function nofont(){
        $this->load->view('../layout/404-page');
    }

}
